<template>
  <div id="aCoursesList" class="bg-fa of">
    <!-- 讲师介绍 开始 -->
    <section class="container">
      <header class="comm-title">
        <h2 class="fl tac">
          <span class="c-333">讲师介绍</span>
        </h2>
      </header>

      <div class="t-infor-wrap" id="image">
        <!-- 讲师基本信息 -->
        <section class="fl t-infor-box c-desc-content">
          <div class="mt20 ml20">
            <section class="t-infor-pic">
<!--              <img :src="this.teacherInfo.avatar" style="width: 150px; height: 150px">-->
              <el-avatar
                shape="circle"
                :size="100"
                :src="teacherInfo.avatar"
                :fit="'fill'"></el-avatar>
            </section>
            <h3 class="hLh30">
              <span class="fsize24 c-333">{{this.teacherInfo.name}}&nbsp;{{this.teacherInfo.career}}</span>
            </h3>
            <section class="mt10">
              <span class="t-tag-bg">{{this.teacherInfo.career}}</span>
            </section>
            <section class="t-infor-txt">
              <p class="mt20">
                {{this.teacherInfo.intro}}
              </p>
            </section>
            <div class="clear"></div>
          </div>
        </section>
        <div class="clear"></div>
      </div>
      <section class="mt30">
        <div>
          <header class="comm-title all-teacher-title c-course-content">
            <h2 class="fl tac">
              <span class="c-333">主讲课程</span>
            </h2>
            <section class="c-tab-title">
              <a href="javascript: void(0)">&nbsp;</a>
            </section>
          </header>
          <!-- /无数据提示 开始-->
          <section class="no-data-wrap" v-if="teacherCourseList.length === 0">
            <em class="icon30 no-data-ico">&nbsp;</em>
            <span class="c-666 fsize14 ml10 vam">没有相关数据，小编正在努力整理中...</span>
          </section>
          <!-- /无数据提示 结束-->
          <article class="comm-course-list">
            <ul class="of">
              <li v-for="teacherCourse in teacherCourseList" :key="teacherCourse.id">
                <div class="cc-l-wrap">
                  <section class="course-img">
                    <img :src="teacherCourse.cover" class="img-responsive" >
                    <div class="cc-mask">
                      <a :href="'/course/' + teacherCourse.id" title="开始学习" target="_blank" class="comm-btn c-btn-1">开始学习</a>
                    </div>
                  </section>
                  <h3 class="hLh30 txtOf mt10">
                    <a :href="'/course/' + teacherCourse.id" :title="teacherCourse.title" target="_blank" class="course-title fsize18 c-333">{{teacherCourse.title}}</a>
                  </h3>
                </div>
              </li>
            </ul>
            <div class="clear"></div>
          </article>
        </div>
      </section>
    </section>
    <!-- /讲师介绍 结束 -->
  </div>
</template>
<script>
import teacher from "@/api/teacher";

export default {
  data() {
    return {
      teacherId: '',
      teacherInfo: {},
      teacherCourseList: []
    }
  },
  created() {
    // 获取路由上的id
    if (this.$route.params && this.$route.params.id) {
      this.teacherId = this.$route.params.id
    }
    this.getTeacherById()
    this.getTeacherCourseById()
    console.log(this.teacherCourseList)
  },
  methods: {
    // 根据id查询讲师信息
    getTeacherById(){
      teacher.getTeacherById(this.teacherId)
        .then(res => {
          this.teacherInfo = res.data.data.teacher
        })
    },
    // 根据讲师id查询课程信息
    getTeacherCourseById() {
      teacher.getTeacherCourseById(this.teacherId)
        .then(res => {
          this.teacherCourseList = res.data.data.teacherCourse
        })
    }
  }

};
</script>
<style scoped>
#image >>> .t-infor-pic img{
  margin: 0;
  width: 100%;
}
</style>
